<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/font.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/custom.css">
    <title>会议系统</title>

</head>
<body>
<%@include file="header.jsp"%>
<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@include file="nav.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">会议系统</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="list-group myList">
                <!--搜索文章的条件-->
                <div class="myTitle">
                    <form class="form-inline" action="${pageContext.request.contextPath}/meeting/meetingList">
                        <div class="form-group">
                            <label for="inlineFormInput" class="sr-only">Name</label>
                            <input id="inlineFormInput" type="text" placeholder="按标题名字查找" class="mr-sm-3 form-control" name="name">
                        </div>
                        <div class="form-group">
                            <input type="submit" value="查询" class="btn btn-primary">
                        </div>
                        <!--选择部门-->
                        <div class="form-group">
                            <select name="dep" class="form-control">
                                <option value="">请选择部门</option>
                                <c:forEach items="${deptList}" var="dept">
                                    <option value="${dept.name}">${dept.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </form>

                    <input id = "addMeet" type="submit" value="发布会议" class="btn btn-primary">


                </div>

                <ul>
                    <c:forEach var="meeting" items="${meetingsByPage}">
                        <li class="list-group-item">
                            <div style="float: right;">
                                <span><strong>状态：</strong>
                                    <c:if test="${meeting.status == 0}">
                                        未开始
                                    </c:if>
                                    <c:if test="${meeting.status == 1}">
                                        进行中
                                    </c:if>
                                    <c:if test="${meeting.status == 2}">
                                        以结束
                                    </c:if>
                                </span>
                            </div>
                            <a href="${pageContext.request.contextPath}/meeting/meetDetail?cid=${meeting.id}">${meeting.title}</a>
                            <p class="h6"><strong>部门：</strong>${meeting.dept_name}</p>
                            <p class="h6"><strong>日期：</strong>${meeting.public_date}</p>
                            <p style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis">
                                ${meeting.content}
                            </p>
                        </li>
                    </c:forEach>
                </ul>

                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous" onclick="last()">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach begin="${startPage}" end="${endPage}" var="i">
                            <c:if test="${i == currentPage}">
                                <li><a href="#" class="act" onclick="toPage(${i})">${i}</a></li>
                            </c:if>
                            <c:if test="${i != currentPage}">
                                <li><a href="#" onclick="toPage(${i})">${i}</a></li>
                            </c:if>
                        </c:forEach>
                        <li>
                            <a href="#" aria-label="Next" onclick="next()">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <footer class="footer">
            <div class="footer__block block no-margin-bottom">
                <div class="container-fluid text-center">
                    <p class="no-margin-bottom">Copyright &copy; 2019.Company <a href="#">东方标准</a></p>
                </div>
            </div>
        </footer>
    </div>
</div>

<!-- JavaScript files-->
<script src="${pageContext.request.contextPath}/assets/vendor/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/popper.js/umd/popper.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/jquery.cookie/jquery.cookie.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/chart.js/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/charts-home.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/front.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/custom.js"></script>
<script>
    <c:if test="${meetMsg != null}">
    location.reload();
    alert('${meetMsg}');
    <%
        session.removeAttribute("meetMsg");
    %>
    </c:if>
    function toPage(page){
        location.href = '${pageContext.request.contextPath}/meeting/meetingList?currentPage=' + page + "&name=${name}";
    }
    function last() {
        var count = ${currentPage - pageCount};
        if(count > 0){
            location.href = '${pageContext.request.contextPath}/meeting/meetingList?currentPage=${currentPage - pageCount}&name=${name}';
        }else{
            location.reload();
            alert("没有上一轮了！");
        }

    }
    function next() {
        var totalPage = ${totalPage};
        var count = ${currentPage + pageCount};
        if(!(count > totalPage)){
            location.href = '${pageContext.request.contextPath}/meeting/meetingList?currentPage=${currentPage + pageCount}&name=${name}';
        }else{
            location.reload();
            alert('没有下一轮了！');
        }
    }
</script>
</body>
</html>
